package com.linkoog.devtools.archive.action;

import com.intellij.ide.highlighter.ArchiveFileType;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.linkoog.devtools.archive.action.zip.ZipFileDialog;
import com.linkoog.devtools.archive.filesystem.gz.GZFileType;
import com.linkoog.devtools.archive.filesystem.sevenzip.SevenZipFileType;
import com.linkoog.devtools.archive.filesystem.tar.TarFileType;
import com.linkoog.devtools.archive.filesystem.tar.TarGzFileType;
import com.linkoog.devtools.archive.filesystem.zip.ArchiveFileTypeExt;
import com.linkoog.devtools.archive.util.SelectedItemsUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class ZipArchiveAction extends AnAction implements DumbAware {



    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {
        final Project project = event.getProject();
        if (project == null) return;

        List<VirtualFile> selectedFiles = SelectedItemsUtil.getSelectedItems(event);
        if (selectedFiles.isEmpty()) return;

        ArrayList<VirtualFile> files = new ArrayList<>();
        for (VirtualFile selectedFile : selectedFiles) {
            if (selectedFile == null) continue;
            if (! selectedFile.isInLocalFileSystem()) continue;

            files.add(selectedFile);
        }

        if (files.isEmpty()) return;

        ZipFileDialog dialog = new ZipFileDialog(project, files);
        dialog.show();
    }




}
